package com.eclink.asset.controller;

import com.eclink.asset.convert.AssetAuditConfigNodeConvert;
import com.eclink.asset.domain.AuditConfigNode;
import com.eclink.asset.domain.AuditUser;
import com.eclink.asset.workflow.service.AuditConfigNodeService;
import com.eclink.asset.workflow.domain.dto.AuditConfigNodeSaveDTO;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 *
 * @author zcc
 * @date 2024-06-04
 */
@Api(description="资产审批配置节点接口列表")
@RestController
@RequestMapping("/wms/assetAuditConfigNode")
public class AssetAuditConfigNodeController extends BaseController {

    @Autowired
    private AuditConfigNodeService service;

    @Autowired
    private AssetAuditConfigNodeConvert convert;

    @ApiOperation("查询资产审批配置节点的审核人员列表")
    @GetMapping("/listUser")
    public ResponseEntity<List<AuditUser>> listUser() {
        List<AuditUser> list = service.listUser();
        return ResponseEntity.ok(list);
    }

    @ApiOperation("查询资产审批配置节点列表")
    @GetMapping("/listAll")
    public ResponseEntity<List<AuditConfigNode>> listAll(String configId) {
        List<AuditConfigNode> list = service.selectListAll(configId);
        return ResponseEntity.ok(list);
    }


    @ApiOperation("新增资产审批配置节点")
    @PreAuthorize("@ss.hasPermi('wms:assetAuditConfigNode:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public ResponseEntity<Integer> add(@RequestBody AuditConfigNode auditConfigNode) {
        return ResponseEntity.ok(service.insert(auditConfigNode));
    }

    @ApiOperation("修改资产审批配置节点")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResponseEntity<Object> update(@RequestBody AuditConfigNodeSaveDTO saveDTO) {
        service.update(saveDTO.getList(), saveDTO.getConfigId());
        return ResponseEntity.ok(1);
    }

    @ApiOperation("删除资产审批配置节点")
    @Log(title = "资产审批配置节点", businessType = BusinessType.DELETE)
	@DeleteMapping("/{id}")
    public ResponseEntity<Integer> remove(@PathVariable Long id) {
        return ResponseEntity.ok(service.deleteById(id));
    }
}
